#include<bits/stdc++.h>
#define REP(i,a,b,c) for(int i=a;i<=b;i+=c)
using namespace std;
const int H=1e6+5;
int T,n,x,ans;
bool h[H];
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--){
        cin>>n;ans=0;
        REP(i,1,H-5,1)h[i]=0;
        REP(i,1,n,1){
            cin>>x;
            if(h[x])
                ans+=x;
            h[x]=1;
        }cout<<ans<<"\n";
    }
    return 0;
}
